﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace CPPEI.Coolzon.UI
{
    /// <summary>
    /// 调色板
    /// </summary>
    public class ColorPlate
    {
        private List<Brush> _colorList;

        /// <summary>
        /// 从调色板中获取颜色，如果没有则返回一个随机颜色
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public Brush GetColor(int index)
        {
            if (this._colorList == null || this._colorList.Count <= index)
            {
                return new SolidColorBrush(Color.FromArgb(255, (byte)new Random().Next(0, 255), (byte)new Random().Next(0, 255), (byte)new Random().Next(0, 255)));
            }
            return this._colorList[index];
        }

        /// <summary>
        /// 添加颜色
        /// </summary>
        /// <param name="color"></param>
        public void AddColor(Brush color)
        {
            if (this._colorList == null)
            {
                this._colorList = new List<Brush>();
            }
            this._colorList.Add(color);
        }

        /// <summary>
        /// 获取所有颜色
        /// </summary>
        /// <returns></returns>
        public List<Brush> GetColorList()
        {
            return _colorList;
        }
    }
}
